using System;
using System.Collections.Generic;
using UnityEngine;

public class BonusAwardManager : MonoBehaviour
{
	public const int BONUS_AWARD = 2;

	private const string SFN_LAST_TIME_BONUS_AWARD = "lastTimeBonusAward";

	public static BonusAwardManager instance;

	private bool _init;

	[SerializeField]
	private List<TypeGame> _bonusAward = new List<TypeGame>();

	public List<TypeGame> BonusAwardConfig
	{
		get
		{
			return _bonusAward;
		}
	}

	private void Awake()
	{
		instance = this;
	}

	private void OnDestroy()
	{
		instance = null;
	}

	public bool IsSetBonus(TypeGame typeGame)
	{
		if (!_bonusAward.Contains(typeGame))
		{
			return false;
		}
		int num = BCWStorage.Get<int>("lastTimeBonusAward" + typeGame);
		if (num == 0)
		{
			return true;
		}
		int serverTime = JSONManager.Instance.GetServerTime();
		if (serverTime == 0)
		{
			return false;
		}
		return GetLocalTime(num).Day != GetLocalTime(serverTime).Day;
	}

	public void SendBonusAwarded(TypeGame typeGame)
	{
		if (IsSetBonus(typeGame))
		{
			int serverTime = JSONManager.Instance.GetServerTime();
			if (serverTime != 0)
			{
				BCWStorage.Set("lastTimeBonusAward" + typeGame, serverTime, true);
			}
		}
	}

	private DateTime GetLocalTime(int timestamp)
	{
		return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(timestamp).ToLocalTime();
	}
}
